<%@page import="java.util.Date"%>
<%@page import="com.gqs.bookstore.dao.CatalogDao"%>
<%@page import="com.gqs.bookstore.dao.impl.CatalogDaoImpl"%>
<%@page import="com.gqs.bookstore.vo.Catalog"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		request.setCharacterEncoding("UTF-8");
	
		String id = request.getParameter("id");
		Long idd = Long.parseLong(id);
		String name = request.getParameter("name");
		String status = request.getParameter("status");
		Date updateAt = new Date();
		
		CatalogDao catalogDao = new CatalogDaoImpl();
		Catalog catalog = catalogDao.findById(idd); //修改肯定是先查找到以后才能进行修改[这里查到后catalog具备主键值]
		//将要修改后的数据set进到catalog对象里,覆盖掉查出来的catalog的各个属性值
		if("禁用".equals(status)){
			catalog.setStatus((Integer)0);
		}
		if("启用".equals(status)){
			catalog.setStatus((Integer)1);
		}
		catalog.setName(name);
		catalog.setUpdateAt(updateAt);
		
		//最终进行修改
		catalogDao.modify(catalog);
		response.sendRedirect("index.jsp");
	%>

</body>
</html>